package com.ruoyi.basedata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.WfzBank;
import com.ruoyi.basedata.service.IWfzBankService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 银行对照Controller
 * 
 * @author lxl
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/basedata/bank")
public class WfzBankController extends BaseController
{
    @Autowired
    private IWfzBankService wfzBankService;

    /**
     * 查询银行对照列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzBank wfzBank)
    {
        startPage();
        List<WfzBank> list = wfzBankService.selectWfzBankList(wfzBank);
        return getDataTable(list);
    }

    /**
     * 导出银行对照列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:export')")
    @Log(title = "银行对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzBank wfzBank)
    {
        List<WfzBank> list = wfzBankService.selectWfzBankList(wfzBank);
        ExcelUtil<WfzBank> util = new ExcelUtil<WfzBank>(WfzBank.class);
        util.exportExcel(response, list, "银行对照数据");
    }

    /**
     * 获取银行对照详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzBankService.selectWfzBankByFid(fid));
    }

    /**
     * 新增银行对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:add')")
    @Log(title = "银行对照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzBank wfzBank)
    {
        return toAjax(wfzBankService.insertWfzBank(wfzBank));
    }

    /**
     * 修改银行对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:edit')")
    @Log(title = "银行对照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzBank wfzBank)
    {
        return toAjax(wfzBankService.updateWfzBank(wfzBank));
    }

    /**
     * 删除银行对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:bank:remove')")
    @Log(title = "银行对照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzBankService.deleteWfzBankByFids(fids));
    }
}
